package cn.zh.npro.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

import cn.zh.npro.R;

/**
 * Created by YST on 2019/3/22 0022.
 */

public class SpinnerAdapter extends BaseAdapter {
    private List<String> list;
    private Context mContext;

    public SpinnerAdapter(List<String> list, Context context) {
        this.list = list;
        mContext = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder ;
        if(convertView == null){
            holder = new ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_rp_,null);
           holder.mTextView = convertView.findViewById(R.id.text2);
            convertView.setTag(holder);
        }else{
            holder = (ViewHolder) convertView.getTag();
        }
        holder.mTextView.setText(list.get(position));
        return convertView;
    }
    public class ViewHolder{
        TextView mTextView;
    }
}
